﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XProject.DataVisit.Model;
using NHibernate;
using NHibernate.Criterion;

namespace XProject.DataVisit.DAL.BaseManager
{
    public class DArea:AbstractSupportDal<Area>
    {
        public IList<Area> GetListByKey(Guid id)
        {
            IList<Area> t = new List<Area>();
            Template.Execute(delegate(ISession session)
            {
                t = session.CreateCriteria<Area>()
                    .Add(Expression.Eq("ParentID", id))
                    .List<Area>();
                return t;
            });
            return t;
        }

        public IList<Area> GetParentList()
        {
            return Session.CreateCriteria<Area>()
                    .Add(Expression.Or(Expression.IsNull("ParentID"), Expression.Eq("ParentID",Guid.Empty)))
                    .List<Area>();
        }
    }
}
